<template>
  <a-form :form="form">
    <a-table
      :columns="dataTable == 'expenditure_plan'?planColumns:remibColumns"
      size="small"
      bordered
      :dataSource="dataSource"
      :pagination="false"
      :scroll="{y:500}"
    >
    </a-table>
  </a-form>

</template>

<script>
  import { httpAction, getAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from 'moment'
  import { postAction, putAction } from '../../api/manage'

  export default {
    name: 'PerformanceModal',
    components: {},
    data() {
      return {
        title: '绩效数据采集',
        visible: false,
        model: {},
        style: { style: { display: 'none' } },
        performanceAppraisalId: '',
        actualValueInput: '',
        isShowTableRow: false,
        actualList: [],
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        internalId: '',//科目id
        projectId: '',//项目id
        budgetAccountId: '',//账套id
        tableId: '',
        validatorRules: {},
        planColumns: [
          {
            title: '绩效目标名称',
            align: 'center',
            dataIndex: 'targetName',
            customRender: (value, row, index) => {
              console.log(value, '绩效目标名称')
              const obj = {
                children: value,
                attrs: {
                  rowSpan: parseInt(row.rowSpanOne)
                }
              }
              return obj
            }
          },
          {
            title: '数据获取方式',
            align: 'center',
            dataIndex: 'dataAcquisitionType',
            customRender: (value, row, index) => {
              console.log(value, '数据采集方式')
              const obj = {
                children: value == '0' ? '采集' : '填报',
                attrs: {
                  rowSpan: parseInt(row.rowSpanTwo)
                }
              }
              return obj
            }
          },
          {
            title: '绩效数据名称',
            align: 'center',
            dataIndex: 'variableName'
          },
          {
            title: '预计目标',
            align: 'left',
            dataIndex: 'expectedValue'
          }
        ],
        remibColumns: [
          {
            title: '绩效目标名称',
            align: 'center',
            dataIndex: 'targetName',
            customRender: (value, row, index) => {
              console.log(value, '绩效目标名称')
              const obj = {
                children: value,
                attrs: {
                  rowSpan: parseInt(row.rowSpanOne)
                }
              }
              return obj
            }
          },
          {
            title: '数据获取方式',
            align: 'center',
            dataIndex: 'dataAcquisitionType',
            customRender: (value, row, index) => {
              console.log(value, '数据采集方式')
              const obj = {
                children: value == '0' ? '采集' : '填报',
                attrs: {
                  rowSpan: parseInt(row.rowSpanTwo)
                }
              }
              return obj
            }
          },
          {
            title: '绩效数据名称',
            align: 'center',
            dataIndex: 'variableName'
          },
          {
            title: '预计目标',
            align: 'left',
            dataIndex: 'expectedValue'
          },
          {
            title: '绩效数据',
            align: 'left',
            dataIndex: 'dataValue',
            scopedSlots: { customRender: 'dataValue' }
          }

        ],
        dataSource: [],
        url: {
          add: '/performance/performanceAppraisal/add',
          edit: '/performance/performanceAppraisal/edit',
          createAppraisal: '/performance/performanceAppraisal/createAppraisal',
          list: '/performance/performanceAppraisal/getAppraisalList1',
          list1: '/performance/performanceAppraisal/getAppraisalList2',
          completeEdit: '/performance/performanceAppraisalComplete/editBatch',
          getDetail: '/performance/performanceVariableRecord/getCollectValueDetail',
          saveOrUpdateRecord: '/performance/performanceVariableRecord/saveOrUpdateRecord',
          saveRecords: '/performance/performanceVariableRecord/saveRecords',
          getInternalId: '/performance/performanceVariableRecord/getInternalId'
        },
        dataTable: ''
      }
    },
    created() {
    },
    methods: {

      add() {
        this.edit({})
      },

      /**
       * @author pqz
       * @description 主方法入口
       * @param record
       */
      edit(id, dataTable) {
        this.dataTable = dataTable
        let obj = {
          mainId: id,
          dataTable: dataTable
        }
        //获取经济科目id
        getAction(this.url.getInternalId, obj).then((res) => {
          if (res.success) {
            console.log()
            let params = {
              mainId: res.result,
              dataTableId: id,
              planOrRemib: 'expenditure_plan' == dataTable ? '1' : '2'
            }
            //获取绩效详情
            getAction(this.url.getDetail, params).then((res) => {
              if (res.success) {
                this.dataSource = res.result
              } else {
                this.$message.warning(res.message)
              }
            })
          } else {

          }
        })

      },
      close() {
        this.$emit('close')
        this.visible = false
      }


    }
  }
</script>

<style lang="less">
  .btn_none {
    .ant-modal-footer {
      display: none;
    }
  }
</style>